function Y = global2local(X, T, R, invR)

if nargin > 3
    Y = invR*(X - T*ones(1, size(X, 2)));
else
    Y = inv(R)*(X - T*ones(1, size(X, 2)));
end
